package cn.edu.scau.cmi.luotiansheng.hibernate.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

import cn.edu.scau.cmi.luotiansheng.spring.util.ApplicationContextUtil;

public class HibernateUtil {
	private static SessionFactory sessionFactory;

	public static SessionFactory getSessionFactory() {
		if(sessionFactory==null) {
			sessionFactory= new Configuration().configure().buildSessionFactory();
			
		}
		return sessionFactory;
		
	}

	public static Session getSession() {
		
		/* return getSessionFactory().getCurrentSession(); */
		return getSessionFactory().openSession();
		
	}
	

}
